package com.jycrm.dao.core.impl;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Types;
import java.util.List;

import oracle.jdbc.OracleTypes;

import com.jycrm.dao.core.AbstractService;
import com.jycrm.dao.core.IJdbcDao;

public class JdbcDaoImpl extends AbstractService implements IJdbcDao {

	public List querySqlUseJdbc(String sql) {
		return jdbcManager.query(sql);
	}

	public void exeuceSqlUseJdbc(String sql) {
		jdbcManager.excute(sql);

	}

	public List excuteProcedures(final String proceduresName,final String[][] paramsIn,final String[][] paramsOut,final int columnCount) {
		return jdbcManager.excuteProcedures( proceduresName, paramsIn, paramsOut, columnCount);
	}
	
	public int callProcedureWithoutParameter(String procedureName){

		Connection conn = jdbcManager.getJdbcConnection();
		int count = 0;
		try {
			CallableStatement cs = conn.prepareCall("{ call "+procedureName+"(?)}");
			cs.registerOutParameter(1,Types.INTEGER);
			int dd=cs.executeUpdate();
			count = cs.getInt(1);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return count;
	}
	

}
